using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Audio;

namespace SoulDoorEngineSmart.Components.Audio
{
    internal class SoundPlayer : SoulDoorEngine.Framework.Components.Component
    {
        private Dictionary<string, SoundEffect> List = new Dictionary<string, SoundEffect>();
        private List<SoundEffectInstance> PlayingList = new List<SoundEffectInstance>();

        internal SoundPlayer()
        {
        }

        internal void Add(string name)
        {
            if (!this.List.ContainsKey(name))
            {
                SoundEffect se = AudioPlayer.MyGame.Content.Load<SoundEffect>(name);
                List.Add(name, se);
            }
            else
            {
                return;
            }
        }

        internal void Play(string name)
        {
            if (this.List.ContainsKey(name))
            {
                SoundEffectInstance sei = List[name].CreateInstance();
                sei.Volume = 1.0f;
                PlayingList.Add(sei);
                sei.Play();
            }
        }

        internal void Pause()
        {
            foreach (SoundEffectInstance item in PlayingList)
            {
                item.Pause();
            }
        }

        internal void Resume()
        {
            foreach (SoundEffectInstance item in PlayingList)
            {
                item.Resume();
            }
        }

        internal void Stop()
        {
            foreach (SoundEffectInstance item in PlayingList)
            {
                item.Stop();
            }
        }
    }
}
